﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>忘记密码</title>

    <link href="~/Content/validform.css" rel="stylesheet" />
    <script src="~/Scripts/Validform_v5.3.2_min.js"></script>
    <script src="~/Scripts/Validform_Datatype.js"></script>

    <script type="text/javascript">
        $(function () {
            $("form").Validform({
                tiptype: 3
            });
            //点击验证码
            $("#valiCode").click(function () {
                this.src = "/Login/GetValidateCode?time=" + (new Date()).getTime();
            });
            //获取下拉框选中的值
            // var type = $('#type option:selected').val();


            if ($("#HEmail").val() == "") {
                $("#DivPhone").css("display", "");
                $("#DivEmail").css("display", "none");
            } else if ($("#HPhone").val() == "") {
                $("#DivEmail").css("display", "");
                $("#DivPhone").css("display", "none");
            } else {
                $("#DivPhone").css("display", "none");
                $("#DivEmail").css("display", "");
                $("#type").change(function () {
                    type = $('#type option:selected').val();
                    if (type == "email") {
                        $("#DivPhone").css("display", "none");
                        $("#DivEmail").css("display", "");
                    } else {
                        $("#DivEmail").css("display", "none");
                        $("#DivPhone").css("display", "");
                    }
                });
            }

        });

        function emailSuccess(data) {
            if (data.Status == 1) {
                $.dialog.tips("发送成功", 1, 'tips.gif');
               // alert("发送成功");
                return true;
            } else {
                return false;
            }
        }

        function phoneSuccess(data) {
            if (data.Status == 1) {
                window.location.href = data.Data;

            } else {
                return false;
            }
        };

        /*-获取短信验证码--*/
        var InterValObj; //timer变量，控制时间
        var count = 120; //间隔函数，1秒执行
        var curCount;//当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6;//验证码长度
        function sendMessage() {
            curCount = count;
            var Phone = $("#phoneTrue").val();
          //  alert(Phone);
            //设置button效果，开始计时
            $("#btnSendCode").attr("disabled", "true");
            $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");

            //向后台发送处理数据
            $.ajax({
                url: '/tools/AdminAjax.ashx?action=get_validate_code&phone=' + Phone + '&sign=user_forget', //目标地址
                type: "Get", //用POST方式传输  
                datatype: "json",
                error: function (XMLHttpRequest, textStatus, errorThrown) { },
                success: function (msg) {
                    InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
                }
            });
        }
        //timer处理函数
        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj);//停止计时器
                $("#btnSendCode").removeAttr("disabled");//启用按钮
                $("#btnSendCode").val("重新发送验证码");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效    
            }
            else {
                curCount--;
                $("#btnSendCode").val("请在" + curCount + "秒内输入验证码");
            }
        }
    </script>

    <style type="text/css">
        .username_text {
            margin-left: 280px;
            width: 150px;
            height: 40px;
            line-height: 40px;
            float: left;
            font-size: 14px;
            color: #999;
            /*margin: 10px 0px;*/
        }

        .login_clear {
            clear: both;
            width: 100%;
            height: 2px;
            margin: 20px 0px 20px 0px;
        }


        .input {
            padding: 5px 4px;
            min-height: 28px;
            line-height: 28px;
            border: 1px solid #d4d4d4;
            background: #fff;
            vertical-align: middle;
            color: #333;
            font-size: 100%;
        }
    </style>



</head>
<body>
    <div class="line10"></div>
    <div class="container">
        <div class="order-process">
            <ul>
                <li class="active">填写账户名</li>
                <li class="active">验证身份</li>
                <li>设置新密码</li>

            </ul>
        </div>
        <div id="main_login">
            <input type="hidden" id="HEmail" value="@ViewBag.email"/>
            <input type="hidden" id="HPhone" value="@ViewBag.phone"/>

            @using (Ajax.BeginForm("SendEmail", new AjaxOptions() { OnSuccess = "emailSuccess" }))
            {
                <input type="hidden" id="Id" name="Id" value="@ViewBag.Id"/>
            @*  <input type="hidden" id="EmailTrue" name="EmailTrue" value="@ViewBag.emailTrue"/>*@
                <div class="username_text">请选择身份验证方式：</div>
                <div class="input-box">
                    @{

                if (ViewBag.phone == "")
                {
                        <select class="input txt" id="type" name="" style="width: 305px; height: 40px">
                            <option value="email">邮箱</option>
                        </select>
                }
                else if (ViewBag.email == "")
                {
                        <select class="input txt" id="type" name="" style="width: 305px; height: 40px">
                            <option value="email">已验证手机</option>
                        </select>
                }
                else
                {
                        <select class="input txt" id="type" name="" style="width: 305px; height: 40px">
                            <option value="email">邮箱</option>
                            <option value="phone">已验证手机</option>

                        </select>
                }
                    }
                </div>
              
                <div class="login_clear"></div>
                <div class="username_text">会员名称：</div>
              
                <div class="input-box">
                    <label id="Name">@ViewBag.name</label>
                </div>
               
                
                <div class="login_clear"></div>
                <div id="DivEmail" style="display: none">
                    <div class="username_text">邮箱地址：</div>
                    <div class="input-box">
                        <label><b>@ViewBag.email</b></label>
                        @* <input type="text" id="Email" name="Email" value="@ViewBag.email" class="input txt" readonly="readonly"/>*@

                    </div>

                    <div class="login_clear"></div>
                    <div style="text-align: center;">
                        <input type="submit" value="发送邮箱验证" id="btnPaySure" name="btnPaySure" class="button" />
                    </div>

                </div>
            }

            <div id="DivPhone" style="display: none">
                @using (Ajax.BeginForm("phone", new AjaxOptions() { OnSuccess = "phoneSuccess" }))
                {
                    <input type="hidden" id="Id" name="Id" value="@ViewBag.Id"/>
                    <input type="hidden" id="phoneTrue" name="phoneTrue" value="@ViewBag.phoneTrue"/>
                    <div class="login_clear"></div>
                    <div class="username_text">已验证手机号：</div>
                    <div class="input-box">
                        <label><b>@ViewBag.phone</b></label>
                        @*  <input type="text" id="phone" name="phone" value="@ViewBag.phone" class="input txt" readonly="readonly" style="width: 300px">*@
                    </div>
                    <div class="login_clear"></div>
                    <div class="username_text">请填写手机验证码：</div>
                    <div>
                        <input type="text" name="validateCode" class="input txt" style="width: 80px" datatype="*" ajaxurl="/tools/AdminAjax.ashx?action=validate_SESSION_SMS_CODE" />
                        <input type="button" id="btnSendCode" value="获取验证码" style="width: 220px" class="button" onclick="sendMessage()" />
                    </div>
                
                    <div class="login_clear"></div>
                    <div style="text-align: center;">
                        <input type="submit" value="提交" id="btnSure" name="btnSure" class="button" />
                    </div>
                }
            </div>
        </div>
        <div class="line10"></div>
    </div>
</body>
</html>

